<?php

namespace App\Timer;

use App\Ws;

class FdClear
{
    static public $server = null;

    public function __construct($server)
    {
        self::$server = $server;
    }

    public function deletFdAfterSecond($second)
    {
        $uidTable = Ws::$table::get('uidTable');
        foreach ($uidTable as $item) {
            if (time() - $item['time'] > $second) {
                self::$server->disconnect($item['fd']);
                $uidTable->del($item['fd']);
            }
        }
        unset($uidTable);
    }
}
